<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/../start.php');//Подключаем файл инициализации
if(($file = $_FILES['upload']) && $file['name'] != 'none' && $file['size'] && $file['tmp_name']) {
error_reporting('E_USER_ERROR');

$wave = new wave($file['tmp_name']);
$chunk = $wave->wavechunk();

if(!is_array($chunk)) {
exit('This is not a wav file.');
}

if($chunk['seconds'] > 999) {

echo "The wav is too long.\r\n\r\n";
print_r($chunk);

} else {

set_time_limit(999);

if($im = $wave->waveimage()) {
header('Content-Type: image/png');
imagepng($im);
} else {
echo "wrong!\r\n\r\n";
print_r($chunk);
}

}

} else {

?>

<form action="?" id="upload_form" method="post" enctype="multipart/form-data">
<input type="file" name="upload" /><br />
<button type="submit">Submit Wav file</button>
</form>

<?php

}

?>